import { ipcMain, dialog } from 'electron'
import { initRepo, isRepo } from './simple-git'
export default function events() {
  ipcMain.on('open-dialog', async (event) => {
    console.log('open-dialog')
    const result = await dialog.showOpenDialog({ properties: ['openDirectory'] })
    console.log(result)
    event.reply('open-dialog-reply', result)
  })

  ipcMain.on('ping', async (event) => {
    console.log('ping')
    event.reply('pong', 'pong')
  })

  ipcMain.on('init-repo', async (event, path) => {
    await initRepo(path)
  })

  ipcMain.on('is-repo', async (event, path) => {
    const result = await isRepo(path)
    event.reply('is-repo-reply', result)
  })
}
